package com.kgcx.common.client.order;

import com.kgcx.common.bean.ReturnData;
import com.kgcx.common.client.order.pojo.Order;
import com.kgcx.common.client.order.pojo.UserMileage;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Paul on 2017/11/16.
 */
@FeignClient(name = "order")
public interface OrderClient {

    /**
     * 创建订单
     *
     * @param placingUserId
     * @param passengerPhone
     * @param isSelf
     * @param orderChannel
     * @param planOrigCityId
     * @param planOrig
     * @param planOrigLng
     * @param planOrigLat
     * @param planDestCityId
     * @param planDest
     * @param planDestLng
     * @param planDestLat
     * @param planMileage
     * @param planPrice
     * @param planDuration
     * @param orderType
     * @param autoType
     * @return
     */
    @PostMapping("order/createOrder")
    String createOrder(@RequestParam("placing_user_id") long placingUserId,
                       @RequestParam("passenger_phone") String passengerPhone,
                       @RequestParam("is_self") int isSelf,
                       @RequestParam("order_channel") int orderChannel,
                       @RequestParam("plan_orig_city_id") int planOrigCityId,
                       @RequestParam("plan_orig") String planOrig,
                       @RequestParam("plan_orig_lng") String planOrigLng,
                       @RequestParam("plan_orig_lat") String planOrigLat,
                       @RequestParam("plan_dest_city_id") int planDestCityId,
                       @RequestParam("plan_dest") String planDest,
                       @RequestParam("plan_dest_lng") String planDestLng,
                       @RequestParam("plan_dest_lat") String planDestLat,
                       @RequestParam("plan_mileage") long planMileage,
                       @RequestParam("plan_price") int planPrice,
                       @RequestParam("plan_duration") int planDuration,
                       @RequestParam("order_type") int orderType,
                       @RequestParam("auto_type") int autoType);

    /**
     * 获取订单详情
     *
     * @param orderNo
     * @return
     */
    @GetMapping("order/getByOrderNo")
    Order getByOrderNo(@RequestParam("order_no") String orderNo);

    /**
     * 获取订单列表
     *
     * @param status
     * @param driverId
     * @param userId
     * @return
     */
    @GetMapping("order/list")
    List<Order> list(@RequestParam("status") Integer status,
                     @RequestParam("driver_id") Long driverId,
                     @RequestParam("user_id") Long userId);

    /**
     * 更新进行中的订单状态
     *
     * @param orderNo
     * @param orderState
     * @return
     */
    @GetMapping("order/stateSwitch")
    void stateSwitch(@RequestParam("order_no") String orderNo,
                     @RequestParam("order_state") Integer orderState);

    /**
     * 取消订单
     *
     * @param orderNo
     * @param cancelType
     * @return
     */
    @GetMapping("order/cancelOrder")
    void cancelOrder(@RequestParam("order_no") String orderNo,
                     @RequestParam("cancel_type") Integer cancelType);

    /**
     * 更新已完成订单
     *
     * @param order
     * @return
     */
    @PostMapping("order/update")
    void update(@RequestBody Order order);

    /**
     * 司机 - 检查司机是否能服务，（入参：司机ID）0-成功，可以接单，161054003 - 司机有代付订单未支付，不能继续服务
     *
     * @param driverId
     * @return
     */
    @GetMapping("order/checkDriverServeState")
    Integer checkDriverServeState(@RequestParam("driver_id") Long driverId);

    /**
     * 获取乘客订单总额
     *
     * @param userId
     * @return
     */
    @GetMapping("order/queryPaiedOrderAmount")
    BigDecimal queryPaiedOrderAmount(@RequestParam("user_id") Long userId);

    /**
     * 获取乘客所有可开票订单
     *
     * @param userId
     * @return
     */
    @GetMapping("order/queryPaiedOrderList")
    List<String> queryPaiedOrderList(@RequestParam("user_id") Long userId);

    /**
     * 获取乘客里程
     *
     * @param userIds
     * @return
     */
    @GetMapping("order/queryUserMileage")
    HashMap<Long, UserMileage> queryUserMileage(@RequestParam("userIds") List<Long> userIds);

    /***
     * 计算完附加费修改订单信息
     *
     * @param json
     * @return
     */
    @GetMapping("order/updateRedis")
    ReturnData updateRedis(@RequestParam("json") String json);
}
